package com.lvy.hczn.transmit.controller;

import com.lvy.hczn.front.common.constant.Constants;
import com.lvy.hczn.front.common.core.domain.AjaxResult;
import com.lvy.hczn.front.common.core.domain.entity.SysDictData;
import com.lvy.hczn.front.common.exception.UtilException;
import com.lvy.hczn.front.common.utils.DictUtils;
import com.lvy.hczn.front.system.domain.business.GoodsBox;
import com.lvy.hczn.front.system.domain.business.Warehouse;
import com.lvy.hczn.mq.rocket.ParamInfo;
import com.lvy.hczn.transmit.service.GoodsBoxService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RequestMapping("/api/dt/index/")
@RestController
@Slf4j
public class IndexController {

    @Autowired
    private GoodsBoxService goodsBoxService;

    @ApiOperation(value = "获取仓库编号", notes = "商品分类同步")
    @PostMapping("wh/code")
    @ResponseBody
    public AjaxResult initWarehouseCode(HttpServletRequest request, @RequestBody ParamInfo<Warehouse> warehouseParamInfo) {
        try {
//           String str = DictUtils.getDictValue(Constants.INTER_TRANSMIT_PLATFORM_SYNC_INFO,Constants.INTER_TRANSMIT_WAREHOUSE_BOX_ENTRY);
            String num = "";
            return AjaxResult.success("操作成功", num);
        } catch (Exception e) {
            if (e instanceof UtilException) {
                return AjaxResult.error(e.getMessage());
            } else {
                log.error("syncSpu同步异常：{}", e);
                return AjaxResult.error("系统异常");
            }
        }
    }

    @ApiOperation(value = "货箱编号查询货箱信息", notes = "货箱编号查询货箱信息")
    @PostMapping("box/supplier")
    @ResponseBody
    public AjaxResult selectBoxSupplierByBoxCode(HttpServletRequest request, @RequestBody ParamInfo<GoodsBox> goodsBoxParamInfo) {
        try {
            return AjaxResult.success("操作成功", goodsBoxService.selectBoxSupplierByBoxCode(request, goodsBoxParamInfo));
        } catch (Exception e) {
            log.error("selectBoxSupplierByBoxCode查询异常异常：", e);
            if (e instanceof UtilException) {
                return AjaxResult.error(e.getMessage());
            } else {
                return AjaxResult.error("系统异常");
            }
        }
    }
}
